// import type { RouteRecordNormalized } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';

// const modules = import.meta.globEager('./modules/*.ts');
const modules = import.meta.glob('./modules/*.ts', { eager: true });

function formatModules(_modules: any, result: RouteRecordRaw[]) {
  Object.keys(_modules).forEach((key) => {
    const defaultModule = _modules[key].default;
    if (!defaultModule) {
      return;
    }
    const moduleList = Array.isArray(defaultModule)
      ? [...defaultModule]
      : [defaultModule];
    result.push(...moduleList);
  });
  return result;
}

// const appRoutes: RouteRecordNormalized[] = formatModules(modules, []);

// export default appRoutes;

export const appRoutes: RouteRecordRaw[] = formatModules(modules, []);

export const appExternalRoutes: RouteRecordRaw[] = [];
